package utils;

import bean.quanpailie;

import java.util.*;

public class test1 {
    public static void main(String[] args) {
    int height[] = {0,1,0,2,1,0,1,3,2,1,2,1};
    String s="asasa";
   int a= Integer.MAX_VALUE;
   int q=9;
   StringBuilder stringBuilder=new StringBuilder("");
   //stringBuilder.deleteCharAt(stringBuilder.length()-1);
PriorityQueue<int []> priorityQueue=new PriorityQueue<>((int[] e,int [] e1)->{ return e1[0]-e[0];});

   Stack stack=new Stack();
   Queue queue=new LinkedList();
   queue.poll();
    Set ss=new HashSet();

    HashMap hashMap=new HashMap();
        System.out.println(countSubstrings("aaa"));

//  int aaa[][]={{1,4,7,11,15},{2,5,8,12,19},{3,6,9,16,22},{10,13,14,17,24},{18,21,23,26,30}};
//       int s1= aaa[0].length;
//        System.out.println(searchMatrix(aaa,100));

    }
    public static int countSubstrings(String s) {
        int n=s.length();
        int  count=0;
        boolean dp[][]=new boolean[n][n];
        for(int i=0;i<n;i++){
            dp[i][i]=true;
        }
        for(int i=0;i<n;i++){
            System.out.println(count);
            for(int j=i;j<n;j++){
                if(i==j){
                    count++;
                    dp[i][j]=true;
                }
                else if(j-i==1){
                    if(s.charAt(i)==s.charAt(j)){
                        count++;
                        dp[i][j]=true;
                    }
                    else{
                        dp[i][j]=false;
                    }

                }
                else{
                    if(s.charAt(i)==s.charAt(j)&&dp[i+1][j-1]==true){
                        dp[i][j]=true;
                        System.out.println(222);
                        count++;
                    }
                    else{
                        dp[i][j]=false;
                    }
                }
            }
        }
        return count;
    }
}
